﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DIS_App_Client.DIS_WS_BusinessLayer;

namespace DIS_App_Client.Helpers
{
    public class CommonHelper
    {
        public static string GetMessage(string name, string area)
        {
            foreach (var item in GlobalVariables.g_colInfoSpecific)
            {
                if (item.Name.Trim().ToUpper() == name.Trim().ToUpper() && item.Area.Trim().ToUpper() == area.Trim().ToUpper())
                {
                    return item.Report;
                }
            }
            return string.Empty;
        }

        public static bool IsNumeric(string data)
        {
            try
            {
                var n = double.Parse(data);
                return true;
            }
            catch
            {
                return false;
            }
        }

        public static ROLE GetRole(EmployeeDTO item)
        {
            var roleDTO = BusService.Instance.Role_SelectByID(item.IDRole);
            if (roleDTO.Name.Trim() == "National Manager")
            {
                return ROLE.NATIONAL;
            }
            else if (roleDTO.Name.Trim() == "Local Manager")
            {
                return ROLE.LOCAL;
            }
            else
            {
                return ROLE.STAFF;
            }
        }

        public static List<DateTime> GetDateRange(DateTime StartingDate, DateTime EndingDate)
        {
            if (StartingDate > EndingDate)
            {
                return null;
            }
            List<DateTime> rv = new List<DateTime>();
            DateTime tmpDate = StartingDate;
            do
            {
                rv.Add(tmpDate);
                tmpDate = tmpDate.AddDays(1);
            } while (tmpDate <= EndingDate);
            return rv;
        }
    }
}
